var express = require('express');
const { uploadFile } = require('tools-factory-tang');
const { update, deleteImg } = require('../api/cinemas.js');
var router = express.Router();

// 处理文件上传接口
router.post('/upload', async function (req, res, next) {
    const { data } = await uploadFile(req, { fileType: "cinemas" });
    const result = await update(data);
    res.send(result);
});


// 删除图片数据
router.delete(`/:_id/imgs/:url`,async function (req, res, next) {
   
    // 从url拿数据
    const { _id, url } = req.params;
    // 获取删除后的最新数据
    const data = await deleteImg({ _id, url })
    res.send(data);

});


module.exports = router;      //暴露router接口